<template>
  <div>
      <div class="biaoDoctor">
          <el-table
        :data="
          searchList.slice(
            (currentPage - 1) * pageSize,
            currentPage * pageSize
          )
        "
        header-align="center"
      >
        <el-table-column type="selection" width="50" align="center">
        </el-table-column>
        <el-table-column
          prop="doctor_id"
          label="编号"
          width="60"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="doctor_name"
          label="姓名"
          align="center"
        ></el-table-column>
        <el-table-column prop="doctor_phone" label="手机号码" align="center">
        </el-table-column>
        <el-table-column prop="doctorTypeName" label="角色" align="center">
        </el-table-column>
        <el-table-column prop="teamName" label="所属团队" align="center">
        </el-table-column>
        <el-table-column prop="doctor_organization" :formatter="servicexian" label="所属机构" align="center">
        </el-table-column>
        <el-table-column label="操作" align="center" width="250px">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small"
              >查看详情</el-button>
            <el-button  type="text" size="small"
              >发消息</el-button>
            <el-button @click="handleClick1(scope.row)" type="text" size="small">编辑</el-button>
            <el-button @click="handleClick2(scope.row)" type="text" size="small"
              > <font color="red">删除</font></el-button>
          </template>
          <!-- <router-link to="/serve06"> 查看详情</router-link>&nbsp;&nbsp;&nbsp;
          <a href="" >发消息</a>&nbsp;&nbsp;&nbsp;
          <router-link to="/serve07"><a href="">编辑</a></router-link>&nbsp;&nbsp;&nbsp;
          <a href=""><font color="red">删除</font></a>&nbsp;&nbsp;&nbsp; -->
        </el-table-column>
      </el-table>
      <div class="block">
      <el-pagination
        align="center"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 30, 40, 50]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="searchList.length"
      >
      </el-pagination>
    </div>
      </div>
  </div>
</template>

<script>
import axios from "axios";
axios.defaults.baseURL = "http://localhost:8080/";
export default {
props: {
    searchList: {
      type: Array,
    },
  },
  data() {
    return {
      list: [],
      currentPage: 1, // 当前页码
      pageSize: 15, // 每页的数据条数
    };
  },
  methods: {
    servicexian(row, column, cellValue, index) {
      console.log(cellValue);
      if (cellValue === 1) {
        return "罗西社区服务中心";
      } else if (cellValue === 2) {
        return "天明社区服务中心";
      } else if (cellValue === 3) {
        return "民进社区服务中心";
      }
    },
    handleClick2(row){
      this.$emit('subFndel',row.doctor_id)
     
    },
    handleClick1(row){
      console.log(row.user_id);
      this.$router.push({
        path:'/serve07',
        query: {
          id: row.doctor_id,
        },
      });
    },
    handleClick(row){
      console.log(row.user_id);
      this.$router.push({
        path:'/serve06',
        query: {
          id: row.doctor_id,
        },
      });
    },
    //每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
      //   alert(`每页 ${val} 条`);
      this.currentPage = 1;
      this.pageSize = val;
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    },
  },
}
</script>

<style>
.biaoDoctor {
  width: 96%;
  height: 100px;
  margin-left: 2%;
}
.block{
  margin-top: 10px;
}
</style>